/*
-- =============================================
-- Author:			Jacqueline Walton
-- Create date:		March 27, 2014
-- Description:		Add Sample Data
-- Last Updated:	March 27, 2014

-- Summary:			This script will add the Crystal Test sample data. 

-- License and Permissions
					 *     https://crystaltest.codeplex.com
					 *
					 * Distributed in whole under the terms of the Apache 2.0 License
					 *
					 *     Copyright 2014, Pixeltrix
					 *
					 * Licensed under the GNU General Public License version 2 (GPLv2) (the "License");
					 * you may not use this file except in compliance with the License.
					 * You may obtain a copy of the License at
					 * 
					 *     https://crystaltest.codeplex.com/license
					 * 
					 * Unless required by applicable law or agreed to in writing, software
					 * distributed under the License is distributed on an "AS IS" BASIS,
					 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
					 * See the License for the specific language governing permissions and
					 * limitations under the License.
					 *
					 *     Date: Fri Mar 28 2014 09:33:33 -0500
-- =============================================
*/


/*
=============================================
 Add project
=============================================
*/

INSERT [dbo].[Projects] ([projectAbbreviation], [projectName]) VALUES (N'EXAMPLE', N'Example')


/*
=============================================
 Add manual test case
=============================================
*/

INSERT [dbo].[TestCases] ([projectAbbreviation], [testCaseId], [testCaseDescription], [active], [testCaseOutdated], [testScriptOutdated], [testCaseSteps], [expectedResults], [testCaseNotes], [dateLastUpdated], [updatedBy], [autoTestClass], [autoMetaDataTable], [autoMetaDataRow], [dateCreated], [createdBy], [dateAutomatedTestCreated], [automatedTestCreatedBy], [testCategory], [automated], [reasonForNotAutomated]) VALUES (N'EXAMPLE', 1, N'Verify a user can log into their Gmail account regardless of whether they have previously logged in or not.', 1, 0, 0, N'For automation example purposes only<br>', N'For automation example purposes only', N'For automation example purposes only', GETDATE(), N'', NULL, NULL, NULL, GETDATE(), N'', NULL, NULL, N'Functional', NULL, NULL)


/*
=============================================
 Install Group
=============================================
*/
INSERT [dbo].[GroupTests] ([projectAbbreviation], [groupTestAbbreviation], [groupTestName], [groupTestDescription], [personalGroupOwner]) VALUES (N'EXAMPLE', N'AUTH', N'Authorization', N'Test cases relating to Gmail authorization.', NULL)

/*
=============================================
Assign Test Case to Group
=============================================
*/
INSERT [dbo].[GroupTestCases] ([projectAbbreviation], [testCaseId], [groupTestAbbreviation]) VALUES (N'EXAMPLE', 1, N'AUTH')

/*
=============================================
 Install Release
=============================================
*/
INSERT [dbo].[Releases] ([projectAbbreviation], [release], [releaseDescription], [releaseDate]) VALUES (N'EXAMPLE', N'Example Release', N'This is an example release', GETDATE() + 30)

/*
=============================================
Assign Test Case to Release
=============================================
*/
INSERT [dbo].[ReleaseTestCases]([projectAbbreviation], [testCaseId], [release]) VALUES (N'EXAMPLE', 1, N'Example Release')

/*
=============================================
 Install Sprint
=============================================
*/
INSERT [dbo].[Sprints]([projectAbbreviation], [sprint], [sprintDescription], [sprintStartDate], [sprintEndDate]) VALUES (N'EXAMPLE', N'Example Sprint', N'This is an example sprint', GETDATE(), GETDATE() + 30 )

/*
=============================================
Assign Test Case to Sprint
=============================================
*/
INSERT [dbo].[SprintTestCases]([projectAbbreviation], [testCaseId], [sprint]) VALUES (N'EXAMPLE', 1, N'Example Sprint')

/*
=============================================
	   Reset Project Browser Info
=============================================
*/
INSERT [dbo].[ProjectBrowserInfo] ([projectAbbreviation], [browserAbbreviation], [showBrowserColumn]) VALUES (N'EXAMPLE', N'CHROME', 1)
INSERT [dbo].[ProjectBrowserInfo] ([projectAbbreviation], [browserAbbreviation], [showBrowserColumn]) VALUES (N'EXAMPLE', N'FF', 1)
INSERT [dbo].[ProjectBrowserInfo] ([projectAbbreviation], [browserAbbreviation], [showBrowserColumn]) VALUES (N'EXAMPLE', N'IE10', 0)
INSERT [dbo].[ProjectBrowserInfo] ([projectAbbreviation], [browserAbbreviation], [showBrowserColumn]) VALUES (N'EXAMPLE', N'IE11', 0)
INSERT [dbo].[ProjectBrowserInfo] ([projectAbbreviation], [browserAbbreviation], [showBrowserColumn]) VALUES (N'EXAMPLE', N'IE8', 0)
INSERT [dbo].[ProjectBrowserInfo] ([projectAbbreviation], [browserAbbreviation], [showBrowserColumn]) VALUES (N'EXAMPLE', N'IE9', 0)
INSERT [dbo].[ProjectBrowserInfo] ([projectAbbreviation], [browserAbbreviation], [showBrowserColumn]) VALUES (N'EXAMPLE', N'MACSAF', 0)
INSERT [dbo].[ProjectBrowserInfo] ([projectAbbreviation], [browserAbbreviation], [showBrowserColumn]) VALUES (N'EXAMPLE', N'WINSAF', 0)

/*
=============================================
	 Install Project Environment Info
=============================================
*/
INSERT [dbo].[ProjectEnvironmentInfo] ([projectAbbreviation], [environment], [baseURL], [baseAdminURL], [defaultEnvironment]) VALUES (N'EXAMPLE', N'QA', N'http://accounts.google.com', NULL, 1)

/*
=============================================
 Create [_Examples_Login] Metadata Table
=============================================
*/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[_Examples_Login]') AND type in (N'U'))
DROP TABLE [dbo].[_Examples_Login]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[_Examples_Login]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[_Examples_Login](
	[LoginID] [int] IDENTITY(1,1) NOT NULL,
	[Description] [varchar](150) NULL,
	[Email] [varchar](100) NULL,
	[Password] [varchar](50) NULL,
	[isFacebook] [bit] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO

/*
=============================================
 Add data for automation
=============================================
*/
SET IDENTITY_INSERT [dbo].[_Examples_Login] ON 
INSERT [dbo].[_Examples_Login] ([LoginID], [Description], [Email], [Password], [isFacebook]) VALUES (1, N'OSTMS Test User', N'ostms.testuser@gmail.com', N't3stus3r', NULL)
SET IDENTITY_INSERT [dbo].[_Examples_Login] OFF

/*
=============================================
 Install automated script
=============================================
*/
UPDATE testcases SET autoTestClass = 'Example_TestScripts.Example_Login, Example_TestScripts', autoMetaDataTable = '_Examples_Login', autoMetaDataRow = 1, automated = 'Yes', automatedTestCreatedBy = null, dateAutomatedTestCreated = GETDATE() WHERE testcaseid = 1 and projectAbbreviation = 'EXAMPLE'
